﻿Imports Models.Security

Namespace Users

    Public Class CompanyVO
        Inherits BaseVO

        Private _companyId As Integer
        Private _code As String
        Private _name As String
        'Private _licenseType As String
        'Private _contact As String

        Private _preferences As New Generic.List(Of CompanyPreferenceVO)

        Sub New()
        End Sub

        Sub New(entity As Data.BaseModel.Company)
            If entity IsNot Nothing Then
                companyId = entity.CompanyId
                name = entity.Name
                code = entity.Code
                'licenseType = entity.LicenseType
                'contact = entity.Contact

                If entity.CompanyPreferences IsNot Nothing Then
                    For Each oItem As Data.BaseModel.CompanyPreference In entity.CompanyPreferences
                        preferences.Add(New CompanyPreferenceVO(oItem))
                    Next
                End If

            End If
        End Sub

        Public Property companyId As Integer
            Get
                Return _companyId
            End Get
            Set(value As Integer)
                _companyId = value
            End Set
        End Property

        <RequiredAtt("name")> _
        Public Property name As String
            Get
                Return _name
            End Get
            Set(value As String)
                _name = value
            End Set
        End Property

        <StringLengthAtt(50, "code", 3)> _
        Public Property code() As String
            Get
                Return _code
            End Get
            Set(ByVal value As String)
                _code = value
            End Set
        End Property

        'Public Property licenseType As String
        '    Get
        '        Return _licenseType
        '    End Get
        '    Set(value As String)
        '        _licenseType = value
        '    End Set
        'End Property

        'Public Property contact As String
        '    Get
        '        Return _contact
        '    End Get
        '    Set(ByVal value As String)
        '        _contact = value
        '    End Set
        'End Property

        Public Property preferences() As Generic.List(Of CompanyPreferenceVO)
            Get
                Return _preferences
            End Get
            Set(ByVal value As Generic.List(Of CompanyPreferenceVO))
                _preferences = value
            End Set
        End Property

    End Class

    Public Class FullCompanyVO
        Inherits CompanyVO

        Private _groups As New Generic.List(Of GroupVO)
        Private _rols As New Generic.List(Of RolVO)

        Sub New()
        End Sub

        Sub New(entity As Data.BaseModel.Company)
            If entity IsNot Nothing Then

                companyId = entity.CompanyId
                name = entity.Name
                code = entity.Code

                If entity.CompanyPreferences IsNot Nothing Then
                    For Each oItem As Data.BaseModel.CompanyPreference In entity.CompanyPreferences
                        preferences.Add(New CompanyPreferenceVO(oItem))
                    Next
                End If

                If entity.Groups IsNot Nothing Then
                    For Each oItem As Data.BaseModel.Group In entity.Groups
                        groups.Add(New GroupVO(oItem))
                    Next
                End If

                If entity.Rols IsNot Nothing Then
                    For Each oItem As Data.BaseModel.Rol In entity.Rols
                        rols.Add(New RolVO(oItem, True))
                    Next
                End If

            End If
        End Sub

        Public Property groups As Generic.List(Of GroupVO)
            Get
                Return _groups
            End Get
            Set(ByVal value As Generic.List(Of GroupVO))
                _groups = value
            End Set
        End Property

        Public Property rols As Generic.List(Of RolVO)
            Get
                Return _rols
            End Get
            Set(ByVal value As Generic.List(Of RolVO))
                _rols = value
            End Set
        End Property
    End Class

End Namespace